{% extends "base.html" %}

{% block content %}

{% block additional_content %}{% endblock %}

<div class="module" id="searchlist">
<table cellspacing="0"> 
<th colspan="2"><a>{% block inner_title %}{% endblock %}</a></th>
</table>
</div>

{% block additional_content_below %}{% endblock %}

<div class="module{% if filters %} filtered{% endif %}" id="searchlist">

{% if show_search %}

{% if not print_view %}  
<div id="toolbar">
  <form id="searchlist-search" action="" method="get">   
  <div> 
    <table cellspacing="0" cellpadding="0" border="0"><tr>
	<td>
		<label for="searchbar"><img src="/media/icons/searchbox.png" alt="Iskanje" /></label> 
		<input type="text" size="40" name="q" value="{{ query }}" id="searchbar" />
		{% for key, values in get_args %}
		{% for value in values %}
		<input type="hidden" name="{{ key }}" value="{{ value }}" />
		{% endfor %}
		{% endfor %}
		<input type="submit" value="Išči" />
	</td>
	<td align="right">
		{% if printable %}<span class="paginator"><a href="?{{ query_args }}&print=1" target="_blank">Natisni</a></span>{% endif %}
	</td></tr></table>
  </div> 
  </form>
</div> 
{% endif %}
<script type="text/javascript">$("searchbar").focus();</script>
{% if filters %}
<div id="searchlist-filter">
  <h2>Filter</h2>
  {{ filter_html }}
</div>
{% endif %}
{% endif %}
<table cellspacing="0"> 
  <thead> 
  <tr>
    <th>#</th>
	{% for field in fields %}
    {% ifequal field.name order_field %}
    <th class="sorted {{ order_asc|yesno:'ascending,descending' }}">
      <a href="?{{ query_args_order }}&o={{ order_asc|yesno:'-,' }}{{ field.name|urlencode }}">{{ field.desc }}</a>
    </th>
    {% else %}
    {% if not field.name %}
    <th>{{ field.desc }}</th>
    {% else %}
    <th><a href="?{{ query_args_order }}&o={{ field.name|urlencode }}">{{ field.desc }}</a></th>
    {% endif %}
    {% endifequal %}
    {% endfor %}
  </tr>
  </thead>
  <tbody>
  {% for item in queryset.object_list %}
  {% block result_pre_row %}{% endblock %}
  <tr class="{% cycle 'row1' 'row2' %}">
    <td>{{ queryset.get_serial_number }}</td>
	{% block result_item %}{% endblock %}
  </tr>
  {% empty %}
  <tr style="height: 50px;">
    <th colspan="{{ fields|length }}" style="text-align: center;"><br/>{% block no_results %}Za vašo poizvedbo ni zadetkov.{% endblock %}</th>
  </tr>
  {% endfor %}
  </tbody> 
</table>
{% if not print_view %}  
<p class="paginator">
  &nbsp;
  {% if queryset.has_previous %}
  <a href="?{{ query_args }}&p={{ queryset.previous_page_number }}">Nazaj</a>
  {% endif %}  
  Stran <b>{{ queryset.number }}</b> od <b>{{ queryset.paginator.num_pages }}</b>
  
  
  {% if queryset.has_next %}
  <a href="?{{ query_args }}&p={{ queryset.next_page_number }}">Naprej</a>
  {% endif %}
</p>  
{% endif %}
</div>
{% endblock %}
